/*
 * Copyright 2014 Graham Smith
 */
package uk.co.wobblycogs.vegas;

import java.nio.file.attribute.FileTime;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 *
 * @author Graham Smith
 */
@Converter(autoApply = true)
public class FileTimeConverter implements AttributeConverter<FileTime, Long> {

	public FileTimeConverter() {
	}

	@Override
	public Long convertToDatabaseColumn(FileTime fileTime) {
		return fileTime.toMillis();
	}

	@Override
	public FileTime convertToEntityAttribute(Long fileTime) {
		return FileTime.fromMillis(fileTime);
	}

}
